package edu.pku.sei.transformation.editor.controller.commands.link;

import org.eclipse.gef.tools.TargetingTool;

import edu.pku.sei.modeler.model.core.MetaModelElement;
import edu.pku.sei.transformation.editor.model.Model;
import edu.pku.sei.transformation.editor.model.TransformationFormalParameter;
import edu.pku.sei.transformation.editor.model.execution.TransformationActualParameter;
import edu.pku.sei.transformation.editor.model.execution.TransformationExecution;

public class TransformationActualParameterCreateCommand extends
		AbstractLinkCreateCommand<TransformationActualParameter, TransformationExecution, MetaModelElement> {
	public TransformationActualParameterCreateCommand(TransformationActualParameter link, TransformationExecution source) {
		super(link, source);
	}
	
	@Override
	public void execute() {
		source.getActualParameters().add(link);
		link.setExecution(source);
		if (target instanceof Model) {
			link.setData((Model) target);			
		} else if (target instanceof TransformationFormalParameter) {
			link.setLateBindingParameter((TransformationFormalParameter) target);
		}
	}
	
	@Override
	public void undo() {
		source.getActualParameters().remove(link);
		link.setExecution(null);
		if (target instanceof Model) {
			link.setData(null);			
		} else if (target instanceof TransformationFormalParameter) {
			link.setLateBindingParameter(null);
		}
	}
	


}
